﻿<UserControl x:Class="CornerstoneRemoteControlClient.Views.AddSetsCommandView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:views="clr-namespace:CornerstoneRemoteControlClient.Views"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">

    <UserControl.Resources>
        <Style x:Key="DescriptionText" TargetType="{x:Type TextBlock}">
            <Setter Property="FontWeight" Value="Bold"/>
            <Setter Property="FontSize" Value="12"/>
            <Setter Property="TextWrapping" Value="Wrap"/>
        </Style>
        <Style x:Key="HeaderText" TargetType="{x:Type TextBlock}">
            <Setter Property="FontWeight" Value="Bold"/>
            <Setter Property="FontSize" Value="14"/>
            <Setter Property="TextWrapping" Value="Wrap"/>
        </Style>
        <Style x:Key="HeaderText2" TargetType="{x:Type TextBlock}">
            <Setter Property="FontWeight" Value="Bold"/>
            <Setter Property="FontSize" Value="16"/>
            <Setter Property="TextWrapping" Value="Wrap"/>
        </Style>

        <!-- Borrowed from http://mark-dot-net.blogspot.com/2009/09/circular-wpf-button-template.html -->
        <Style x:Key="MyFocusVisual">
            <Setter Property="Control.Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Control}">
                        <Grid Margin="8">
                            <Ellipse                    
                                Name="r1"                    
                                Stroke="Black"                    
                                StrokeDashArray="2 2"                    
                                StrokeThickness="1"/>
                            <Border                    
                                Name="border"                    
                                Width="{TemplateBinding ActualWidth}"                    
                                Height="{TemplateBinding ActualHeight}"                    
                                BorderThickness="1"                    
                                CornerRadius="2"/>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="CircleButton" TargetType="Button">
            <Setter Property="OverridesDefaultStyle" Value="True"/>
            <Setter Property="Margin" Value="2"/>
            <Setter Property="FocusVisualStyle" Value="{StaticResource MyFocusVisual}"/>
            <Setter Property="Background" Value="#FF6DB4EF"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <Grid>
                            <Ellipse Fill="{TemplateBinding Background}"/>
                            <Ellipse>
                                <Ellipse.Fill>
                                    <RadialGradientBrush>
                                        <GradientStop Offset="0" Color="#00000000"/>
                                        <GradientStop Offset="0.88" Color="#00000000"/>
                                        <GradientStop Offset="1" Color="#80000000"/>
                                    </RadialGradientBrush>
                                </Ellipse.Fill>
                            </Ellipse>
                            <Ellipse Margin="10" x:Name="highlightCircle" >
                                <Ellipse.Fill >
                                    <LinearGradientBrush >
                                        <GradientStop Offset="0" Color="#50FFFFFF"/>
                                        <GradientStop Offset="0.5" Color="#00FFFFFF"/>
                                        <GradientStop Offset="1" Color="#50FFFFFF"/>
                                    </LinearGradientBrush>
                                </Ellipse.Fill>
                            </Ellipse>
                            <ContentPresenter x:Name="content" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsPressed" Value="True">
                                <Setter TargetName="highlightCircle" Property="Fill">
                                    <Setter.Value>
                                        <LinearGradientBrush StartPoint="0.3,0" EndPoint="0.7,1">
                                            <GradientStop Offset="0" Color="#50FFFFFF"/>
                                            <GradientStop Offset="0.5" Color="#00FFFFFF"/>
                                            <GradientStop Offset="1" Color="#50FFFFFF"/>
                                        </LinearGradientBrush>
                                    </Setter.Value>
                                </Setter>
                                <Setter TargetName="content" Property="RenderTransform">
                                    <Setter.Value>
                                        <TranslateTransform Y="0.5" X="0.5"/>
                                    </Setter.Value>
                                </Setter>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <BooleanToVisibilityConverter x:Key="BoolToVisibility"/>
    </UserControl.Resources>

    <Grid>
        <Rectangle StrokeThickness="0.5" Stroke="Black"/>

        <StackPanel Margin="10">

            <StackPanel Orientation="Horizontal" Margin="0,0,0,5">
                <TextBlock Text="Command:" Style="{StaticResource HeaderText2}" Margin="0,0,5,0" VerticalAlignment="Center"/>
                <TextBlock Text="{Binding Name}" Style="{StaticResource HeaderText}" VerticalAlignment="Center"/>
            </StackPanel>
            <TextBlock Text="{Binding Description}" Style="{StaticResource DescriptionText}"/>

            <StackPanel Margin="0,15,0,5" Orientation="Horizontal">
                <TextBlock Text="Parameters:" Style="{StaticResource HeaderText2}" VerticalAlignment="Center"/>
                <Button Width="20" Height="20" Style="{StaticResource CircleButton}" Margin="10,0" Command="{Binding AddSetCommand}">
                    <Button.Content>
                        <TextBlock Text="+" FontWeight="Bold" FontSize="20" Margin="0,-6,0,0"/>
                    </Button.Content>
                </Button>
            </StackPanel>

            <Grid>
                <Rectangle StrokeThickness="0.5" Stroke="Black" Visibility="{Binding HasSets, Converter={StaticResource BoolToVisibility}}"/>
                <ScrollViewer VerticalScrollBarVisibility="Auto" MaxHeight="200" Margin="2">
                    <ItemsControl ItemsSource="{Binding Sets.ObservableCollection}">
                        <ItemsControl.ItemTemplate>
                            <DataTemplate>
                                <views:DeletableParameterView/>
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                    </ItemsControl>
                </ScrollViewer>
            </Grid>

            <views:CommandSyntaxView Margin="0,10,0,5" DataContext="{Binding}"/>
        </StackPanel>
    </Grid>
</UserControl>
